package com.mojo.io;

import java.io.*;

/**
 * 文件过滤
 *
 * @author <a href="mailto:mojo_jj@163.com">Mojo</a>
 */
public class FileFilter01 {
    public static void main(String[] args) {
        //File file = new File("e:");
        //filenameFilter(file);
        //File f = new File("my.properties");
        //System.out.println(f.isFile());
        //try {
        //    BufferedInputStream stream = new BufferedInputStream(new FileInputStream(f));
        //    int size;
        //    if (-1 != (size = stream.read())) {
        //        System.out.println(size);
        //    }
        //
        //} catch (Exception e) {
        //    e.printStackTrace();
        //}

        try (ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("object.data"));){
            MyUser object = new MyUser("mojo");
            output.writeObject(object);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void filenameFilter(File file) {
        String[] list = file.list((dir, name) -> {
            //System.out.println(dir);
            System.out.println(name);
            if (name.contains("java")) {
                return true;
            }
            return false;
        });
    }

    private static class MyUser implements  Serializable{
        private String name;

        public MyUser(String name) {
            this.name = name;
        }
    }
}

